<?php
    header('Access-Control-Allow-Origin: *');
    header('Content-Type:application/json;charset=utf-8');
    $con = mysqli_connect("127.0.0.1","root","root","mydb");
    $keyword = $_GET['keyword'];
    $keyword = isset($_GET['keyword']) ? trim($_GET['keyword']) : '';
    $sql = "SELECT * FROM lesson AS l LEFT JOIN tch_info AS t ON l.teacher_id = t.t_id WHERE  l.l_id LIKE '%$keyword%' OR l.l_name LIKE '%$keyword%' OR t.t_name LIKE '%$keyword%';";
    $res = mysqli_query($con,$sql);
    $list = array();
    while($row = mysqli_fetch_array($res)){
        $item = array(
            'l_id' => $row['l_id'],
            'l_name' => $row['l_name'],
            'l_time' => $row['l_time'],
            'l_place' => $row['l_place'],
            't_name' => $row['t_name'],
        );
        array_push($list,$item);
    }
    echo json_encode($list);
    mysqli_close($con);
?>